# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=proj

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=4.8.0
pkgrel=1
pkgdesc="Cartographic projection software (PROJ.4) (mingw-w64)"
arch=(any)
url="http://proj.osgeo.org"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
groups=("${MINGW_PACKAGE_PREFIX}")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-libtool")
options=('staticlibs' 'strip')
source=("http://download.osgeo.org/proj/${_realname}-${pkgver}.tar.gz")
md5sums=('d815838c92a29179298c126effbb1537')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  [[ -d "$srcdir/build-${MINGW_CHOST}" ]] && rm -rf "$srcdir/build-${MINGW_CHOST}"
  mkdir "$srcdir/build-${MINGW_CHOST}"
  cd "$srcdir/build-${MINGW_CHOST}"

    ../${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}
    make
}

package() {
    cd "$srcdir/build-${MINGW_CHOST}"
    make DESTDIR="$pkgdir" install
    find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
}
